package br.com.aquinoevasconcelos.servlets.orcamento;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import br.com.aquinoevasconcelos.fachada.Fachada;
import br.com.aquinoevasconcelos.modelos.Orcamento;

@WebServlet("/ListaOrcamento")
public class ListaOrcamento extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public ListaOrcamento() {
		super();
	}

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		Fachada fachada = Fachada.getInstancia();
		ArrayList<Orcamento> orcamentos;

		orcamentos = (ArrayList<Orcamento>) fachada.listaOrcamento();
		request.setAttribute("listaOrcamento", orcamentos);

		RequestDispatcher rd = request
				.getRequestDispatcher("/admin/pedidos_orcamento.jsp");
		rd.forward(request, response);

		request.getRequestDispatcher("/admin/pedidos_orcamento.jsp").include(
				request, response);

	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}

}